# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/24 21:59

"""

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

#1.使用xpath选择器,使用分段获取元素,并显示id为china的所有城市
wd = webdriver.Chrome()
wd.get('https://cdn2.byhy.net/files/selenium/test1.html')

##根据id获取元素
china=wd.find_element(By.XPATH,"//div[@id='china']")
elements=china.find_elements(By.XPATH,'.//p')
for element in elements:
    print(element.get_attribute('innerHTML'))
sleep(2)
